﻿using System.Collections.Generic;

namespace MVCStore.Views.Page
{
	/// <summary>
	/// View model for rendering page content with table of contents if there are children
	/// and rendering a link back to the parent if there is a parent....
	/// </summary>
	public class PageModel
	{
		public PageModel()
		{
			Children = new List<KeyValuePair<int, string>>();
		}

		/// <summary>
		/// The content id of this node
		/// </summary>
		public int ContentNodeId { get; set; }
		
		/// <summary>
		/// The content id of the parent node
		/// </summary>
		public int ParentNodeId { get; set; }
		
		/// <summary>
		/// The title of the page
		/// </summary>
		public string PageTitle { get; set; }
		
		/// <summary>
		/// The content for the page
		/// </summary>
		public string PageContent { get; set; }

		/// <summary>
		/// The children for this page that we want to list in a TOC
		/// the pairs are node id and page title.
		/// </summary>
		public IList<KeyValuePair<int, string>> Children { get; set; }

		/// <summary>
		/// Adds a child.
		/// </summary>
		/// <param name="nodeId">The node id.</param>
		/// <param name="title">The title.</param>
		public void AddChild(int nodeId, string title)
		{
			Children.Add(new KeyValuePair<int, string>(nodeId, title));
		}
	}
}
